/**
 * 
 */
package com.gkwave.action.service;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gkwave.module.bean.MessageBean;
import com.gkwave.module.bean.TransportRegisterBean;
import com.gkwave.module.dao.TransportRegisterDAO;

/**
 * @author Administrator
 * 
 */
public class TransportHomeService extends BaseService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7479513565356094444L;

	/**
	 * 
	 */
	public TransportHomeService() {
		// TODO Auto-generated constructor stub
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.gkwave.action.servelt.BaseServlet#procesRequest(javax.servlet.http
	 * .HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public void procesRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String idUser = request.getParameter("idUser");
		xmlResponse = null;
		out = response.getWriter();
		if (idUser!=null) {
			try {
				Integer id_User = Integer.parseInt(idUser);
				TransportRegisterDAO dao = new TransportRegisterDAO();
				Object obj = dao.getActiveRegistration(id_User);

				if (obj instanceof MessageBean) {
					xmlResponse = ((MessageBean) obj).marsel((MessageBean) obj);
				} else if (obj instanceof TransportRegisterBean){
					xmlResponse = ((TransportRegisterBean) obj).marsel((TransportRegisterBean) obj);
				}

			} catch (NumberFormatException e) {
				// TODO: handle exception
				e.printStackTrace();
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		}
		System.out.println(xmlResponse);
		out.println(xmlResponse);
	}

}
